package debtbundler.logging;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.logging.LogManager;

public class ConfigurationReader {
	
	public static final String JUL_DEFAULT_CONF = "logging/jul_logging.properties";
	
	
	public static void setDefaultConf() {
		readJULConf(JUL_DEFAULT_CONF);
	}
	
	/**
	 * Reads and sets <code>java.util.logging</code> configuration in the specified path.
	 * 
	 * @param path	path of the configuration file
	 */
	public static void readJULConf(String path) {
		FileInputStream ins;
		try {
			ins = new FileInputStream(path);
			LogManager.getLogManager().readConfiguration(ins);
			System.out.println("Found log configuration");
			ins.close();
		} catch (FileNotFoundException e) {
			System.err.println("Could not find log configuration file " + path);
		} catch (IOException e) {
			System.err.println("Error when reading log configuration file");
			e.printStackTrace();
		}
	}

}
